package com.mxwl.cbg.common.model.source.role;

import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * &#064;Description:  资产，包括现金、储备金、善恶、精力、存银、行囊扩展、所有道具
 */
@Data
public class AssetsProp {
    /// 基本属性
    //现金
    private Long iCash;
    //储备金
    private Long iLearnCash;
    //善恶
    private Long iGoodness;
    //精力
    private Long energy;
    //存银
    private Long iSaving;
    //行囊扩展
    private Integer iPcktPage;

    /// 所有的道具在AllEquip字段
//    Map<String, AssetsProp.Prop> all_props;
    // 已装备道具
    List<Prop> using_equips = new ArrayList<>();
    //未准备道具
    List<Prop> not_using_equips = new ArrayList<>();
    //拆售道具
    List<Prop> split_props = new ArrayList<>();

    @Data
    public static class Prop {
        private String equip_sn;
        private String cDesc;
        private Integer iType;
        private int obj_level;
        private int can_split_agent;

        /// 以下是可拆售装备才有的字段
        private String eip;
        private Integer is_split_sale;
    }

    public void setAll_props(Map<String, Prop> all_props) {
        List<Integer> ls = Arrays.asList(187, 188, 189, 190, 191);
        for (String key : all_props.keySet()) {
            int pos = Integer.parseInt(key);
            Prop prop = all_props.get(key);
            if (prop.is_split_sale != null && prop.is_split_sale == 1) {
                split_props.add(prop);
            } else if ((pos >= 1 && pos <= 6) || ls.contains(pos)) {
                using_equips.add(prop);
            } else {
                not_using_equips.add(prop);
            }
        }
    }
}
